package _spring_test._DataBinder;

import org.springframework.beans.MutablePropertyValues;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.validation.DataBinder;

public class DataBinderTest {

    public static void main(String[] args) {
//        ApplicationContext ac = new ClassPathXmlApplicationContext("DataBinder/applicationContext-DataBinder.xml");
//        Product product = (Product) ac.getBean("product");
//        System.out.println(product.getName());

        Product product = new Product();
        DataBinder dataBinder = new DataBinder(product);

        MutablePropertyValues mpv = new MutablePropertyValues();
        mpv.addPropertyValue("id", "1");
        mpv.addPropertyValue("name", "2");
        mpv.addPropertyValue("sort", 3);
        mpv.addPropertyValue("desc", "444");

        dataBinder.bind(mpv);

        System.out.println(product);
    }
}
